
<script type="text/html" template>
  <link rel="stylesheet" href="{{ layui.setter.base }}style/login.css?v={{ layui.admin.v }}-1" media="all">
</script>

<!-- nav部分 -->
<div class="page">
<div class="layui-header header" winter>
  <!-- 公司logo -->
  <a class="logo layui-hide-xs" href="/index.html" id="siteLogo"></a>
  <ul class="layui-nav xxpay-nav" lay-filter="xxpay_nav">
    <li class="layui-nav-item"><a href="../../../../index.html">首页</a></li>
    <li class="layui-nav-item"><a href="../../../../demo.html">支付体验</a></li>
    <li class="layui-nav-item"><a lay-href="/user/login"><button class="layui-btn mch-login">商户登录</button></a></li>
  </ul>

  <div class="layadmin-user-login-main" style="padding-top: 50px;">
    <div class="layadmin-user-login-box layadmin-user-login-header">
      <div class="login-text"><img class="layui-hide-md layui-hide-lg layui-hide-sm" src="layui/images/imgs/mch_mobile.png"><img class="layui-hide-xs" src="layui/images/imgs/mch.png">商户注册</div>
      <p class="siteTitle layui-hide-xs"></p>
    </div>
    <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
      <div class="layadmin-user-login-box-bg">
        <div class="layui-form-item">
          <img class="xxpay-icon" src="layui/images/imgs/username.png">
          <input type="text" name="name" id="LAY-user-login-nickname" lay-verify="nickname" placeholder="商户名称" class="layui-input">
        </div>
        <div class="layui-form-item">
          <img class="xxpay-icon" src="layui/images/imgs/cellphone.png" style="width: 18px;height: 24px;">
          <input type="text" name="mobile" id="LAY-user-login-cellphone" lay-verify="phone" placeholder="手机" class="layui-input">
        </div>
        <div class="layui-form-item">
          <img class="xxpay-icon" src="layui/images/imgs/vercode.png">
          <div class="layui-row" style="width: 100%">
            <div class="layui-col-xs7">
              <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="验证码" class="layui-input">
            </div>
            <div class="layui-col-xs5">
              <div style="margin-left: 10px;">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid" id="LAY-user-reg-getsmscode">获取验证码</button>
              </div>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <img class="xxpay-icon" src="layui/images/imgs/email.png" style="width: 20px;height: 20px;">
          <input type="text" name="email" id="LAY-user-login-email" lay-verify="required|email" placeholder="邮箱" class="layui-input">
        </div>
        <input type="hidden" name="type" value="2">
        <div class="layui-form-item">
          <img class="xxpay-icon" src="layui/images/imgs/password.png">
          <input type="password" name="password" id="LAY-user-login-password" lay-verify="pass" placeholder="密码" class="layui-input" autocomplete="new-password">
        </div>
        <div class="layui-form-item">
          <img class="xxpay-icon" src="layui/images/imgs/password.png">
          <input type="password" name="repass" id="LAY-user-login-repass" lay-verify="required" placeholder="确认密码" class="layui-input">
        </div>

        <div class="layui-form-item">
          <input type="checkbox" name="agreement" lay-skin="primary" title="同意商户协议" checked>
        </div>
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-fluid login-opacity06" lay-submit lay-filter="LAY-user-reg-submit" id="login-btn2">注 册</button>
        </div>
        <div class="layui-trans layui-form-item layadmin-user-login-other">
          <a lay-href="/user/login" class="layadmin-user-jump-change">用已有帐号登入</a>
        </div>
      </div>
    </div>
  </div>
</div>
<div style="height: 300px"></div>
</div>
<!-- footer部分 -->
<div class="footer layui-hide-xs">
  <div class="layui-container">
    <div class="layui-row footer-contact">
      <div class="layui-col-xs12 layui-col-md6 layui-row">
        <div class="layui-col-xs4 layui-col-md4">
          <h2 style="color: #ffffff">关于我们</h2><br /><br /><br />
          <a href="javascript:void(0);">关于我们</a><br /><br />
        </div>
        <div class="layui-col-xs4 layui-col-md4">
          <h2>服务支持</h2><br /><br /><br />
          <a href="javascript:void(0);">开发文档</a>
        </div>
        <div class="layui-col-xs4 layui-col-md4">
          <h2>联系我们</h2><br /><br /><br />
          <a id="serviceTel"></a><br /><br />
          <a id="serviceQQ"></a><br /><br />
        </div>
      </div>
      <div class="layui-col-xs6 layui-col-md6 layui-hide-xs">
        <div style="width:50%;margin-left: 50%">
          <h2>合作伙伴</h2><br /><br /><br />
          <img src="/images/alipay.png"/>&nbsp;&nbsp;
          <img src="/images/wxpay.png"/>
        </div>
      </div>
    </div>
    <div id="copyRight" style="color: rgba(255,255,255,0.4);margin:20px auto;text-align: center"></div>
  </div>
</div>

<script>
layui.use(['admin', 'form', 'user'], function(){
  var $ = layui.$
  ,admin = layui.admin
  ,form = layui.form;

  //变更网站标题
  var siteInfo = layui.data(layui.setter.tableName).siteInfo;
  $('.siteTitle').text(siteInfo.siteTitle);
  $("#siteLogo").append('<img src="'+siteInfo.siteLogo+'" style="height: 30px;" alt="'+siteInfo.siteTitle+'">');
  $('#copyRight').text(siteInfo.copyRight);
  $("#serviceTel").append(siteInfo.serviceTel);
  $("#serviceQQ").append(siteInfo.serviceQQ);

  form.render();
  
  //发送短信验证码
  admin.sendAuthCode({
    elem: '#LAY-user-reg-getsmscode'
    ,elemPhone: '#LAY-user-login-cellphone'
    ,elemVercode: '#LAY-user-login-vercode'
    ,ajax: {
      url:  layui.setter.baseUrl + '/auth/sms_send', //实际使用请改成服务端真实接口
    }
  });

  //提交
  form.on('submit(LAY-user-reg-submit)', function(obj){
    var field = obj.field;
    
    //确认密码
    if(field.password !== field.repass){
      return layer.msg('两次密码输入不一致');
    }
    
    //是否同意用户协议
    if(!field.agreement){
      return layer.msg('你必须同意用户协议才能注册');
    }
    
    //请求接口
/*    admin.req({
      url: './json/user/reg.js' //实际使用请改成服务端真实接口
      ,data: field
      ,done: function(res){        
        layer.msg('注册成功', {
          offset: '15px'
          ,icon: 1
          ,time: 1000
        }, function(){
          location.hash = '/user/login'; //跳转到登入页
        });
      }
    });*/

    admin.req({
      type: 'post',
      url: layui.setter.baseUrl + '/auth/register',
      data: field,
      success: function(res){
        console.log(res);
        if(res.code == 0){
          layer.alert(
                  "注册成功,工作人员会24小时内审核您的信息.",
                  {title: "注册成功"},
                  function(index) {
                    layer.close(index);
                    $("#login").trigger("click");
                  })
        }
      }
    })
    
    return false;
  });

  $(".layui-input").keyup(function(){
    //如果三个输入框都存在值， 则按钮不在置灰
    if($("#LAY-user-login-nickname").val().length > 0 && $("#LAY-user-login-password").val().length > 0 && $("#LAY-user-login-repass").val().length > 0 &&
            $("#LAY-user-login-vercode").val().length > 0 && $("#LAY-user-login-cellphone").val().length > 0 && $("#LAY-user-login-email").val().length > 0){
      $('#login-btn2').removeClass('login-opacity06').addClass('login-opacity10');
    }else{
      $('#login-btn2').removeClass('login-opacity10').addClass('login-opacity06');
    }
  });
});
</script>